//
// Created by Administrator on 2024/3/26.
//

#include<bits/stdc++.h>

using namespace std;

int main() {

    vector<int> A(5, 0);
    while (cin >> A[0] >> A[1] >> A[2] >> A[3] >> A[4]) {
        int best = 0;
        for (int a = 0; a < 5; a++)
            for (int b = 0; b < 5; b++)
                for (int c = 0; c < 5; c++)
                    for (int d = 0; d < 5; d++)
                        for (int e = 0; e < 5; e++) {
                            if (a == b || a == c || a == d || a == e || b == c || b == d || b == e || c == d ||
                                c == e || d == e)
                                continue;
                            if (A[a] == 0 || A[d] == 0)continue;
                            int X = A[a] * 100 + A[b] * 10 + A[c];
                            int Y = A[d] * 10 + A[e];
                            best = max(best, X * Y);
                        }
        cout << best << endl;
    }


    return 0;
}